import React, { PureComponent } from 'react';
import {Table, List, Icon, Tag, Card, Divider } from 'antd';
import styles from '../styles.less';
import DescriptionList from '@/components/DescriptionList';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';


const { Description } = DescriptionList;

class DeviceInfo extends PureComponent {
    constructor(props) {

        super(props);
        let deviceCode = -1;
        if (!props.match.params.deviceCode) {
            deviceCode = props.match.params.deviceCode;
        }

        const project = {
            "code": 1153208092079423500,
            "name": "内燃机",
            "projectCode": 1148784465300947000,
            "typeCode": 1153208091941011500,
            "modeCode": 1153208092012314600,
            "linkedCode": 1153208077172867000,
            "address": null,
            "memo": null,
            "delete": 0,
            "current": 1,
            "version": 1,
            "modeName": "内燃机",
            "typeName": "内燃机",
            "projectName": "XXX医院",
            "linkedDeviceName": "新密能源站"
          };
        this.state = {
            projectData: project,
            deviceCode
        };
    }

    componentWillReceiveProps(nextProps) {
        this.setState({
            projectData: nextProps.eseModel.eseProject
        });
    }

    



    render() {

        const tags = [
            {
              "code": 1153206470796378000,
              "deviceCode": 1153200709580095500,
              "name": "发电量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206470867681300,
              "deviceCode": 1153200709580095500,
              "name": "耗气量",
              "value": null,
              "unit": "Nm3/h",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206470913818600,
              "deviceCode": 1153200709580095500,
              "name": "耗电量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206470955761700,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的烟气热量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206470997704700,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的中冷水热量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206471035453400,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的缸套水水热量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206471077396500,
              "deviceCode": 1153200709580095500,
              "name": "供生活热水的缸套水热量",
              "value": null,
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153206471765262300,
              "deviceCode": 1153200709580095500,
              "name": "状态",
              "value": null,
              "unit": "",
              "memo": "状态点",
              "delete": 0,
              "current": 1,
              "version": 1
            }
          ];
        const tag_cloumns = [{ title: "编号", key: "code", dataIndex: "code" },
      
        { title: "名称", key: "name", dataIndex: "name" },
        { title: "值", key: "value", dataIndex: "value" },
        { title: "单位", key: "unit", dataIndex: "unit" },
        { title: "备注信息", key: "memo", dataIndex: "memo" }];

        const parameters = [
            {
              "code": 1153204915925942300,
              "deviceCode": 1153200709580095500,
              "name": "发电量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204915988856800,
              "deviceCode": 1153200709580095500,
              "name": "耗气量",
              "group": null,
              "type": "采集点",
              "unit": "Nm3/h",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204916047577000,
              "deviceCode": 1153200709580095500,
              "name": "耗电量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204916106297300,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的烟气热量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204916173406200,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的中冷水热量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204916236320800,
              "deviceCode": 1153200709580095500,
              "name": "进溴化锂的缸套水水热量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204916299235300,
              "deviceCode": 1153200709580095500,
              "name": "供生活热水的缸套水热量",
              "group": null,
              "type": "采集点",
              "unit": "kW",
              "memo": "测量点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153204917431697400,
              "deviceCode": 1153200709580095500,
              "name": "状态",
              "group": null,
              "type": "采集点",
              "unit": "",
              "memo": "状态点",
              "delete": 0,
              "current": 1,
              "version": 1
            }
          ];

        const parameter_column = [{ title: "编号", key: "code", dataIndex: "code" },
    
        { title: "名称", key: "name", dataIndex: "name" },
        { title: "参数类型", key: "type", dataIndex: "type" },
        { title: "单位", key: "unit", dataIndex: "unit" },
        { title: "备注信息", key: "memo", dataIndex: "memo" }];
        const indexes = [
            {
              "code": 1153203795883196400,
              "deviceCode": 1153200709580095500,
              "name": "发电效率",
              "type": "指标点",
              "unit": "%",
              "memo": "计算点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153203796084523000,
              "deviceCode": 1153200709580095500,
              "name": "负载率",
              "type": "指标点",
              "unit": "%",
              "memo": "计算点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153203796126466000,
              "deviceCode": 1153200709580095500,
              "name": "发电气耗",
              "type": "指标点",
              "unit": "Nm3/kWh",
              "memo": "计算点",
              "delete": 0,
              "current": 1,
              "version": 1
            },
            {
              "code": 1153203796180992000,
              "deviceCode": 1153200709580095500,
              "name": "自用电率",
              "type": "指标点",
              "unit": "%",
              "memo": "计算点",
              "delete": 0,
              "current": 1,
              "version": 1
            }
          ];

        const index_columns = [{ title: "编号", key: "code", dataIndex: "code" },
      
        { title: "名称", key: "name", dataIndex: "name" },
        { title: "指标类型", key: "type", dataIndex: "type" },
        { title: "单位", key: "unit", dataIndex: "unit" },
        { title: "备注信息", key: "memo", dataIndex: "memo" }];

        const { projectData, deviceCode } = this.state;
        const { eseModel } = this.props;

        return (
            <PageHeaderWrapper title="设备详情页"  >
                <Card bordered={false} >
                    <DescriptionList size="large" title="基本信息" style={{ marginBottom: 32 }}>
                        <Description term="编号">{projectData.code}</Description>
                        <Description term="名称">{projectData.name}</Description>
                        <Description term="项目">{projectData.projectName}</Description>
                        <Description term="类型">{projectData.typeName}</Description>
                        <Description term="型号">{projectData.modeName}</Description>
                        <Description term="所属系统">{projectData.linkedDeviceName}</Description>
                        <Description term="位置">{projectData.address}</Description>
                        <Description term="备注信息">{projectData.memo}</Description>
                    </DescriptionList>
                    <Divider style={{ marginBottom: 32 }} />
                    <div className={styles.title}>设备参数</div>
                    <Table
                        style={{ marginBottom: 24 }}
                        pagination={false}

                        dataSource={tags}
                        columns={tag_cloumns}
                        rowKey="code"
                    />
                    <Divider style={{ marginBottom: 32 }} />
                    <div className={styles.title}>设备指标</div>
                    <Table
                        style={{ marginBottom: 24 }}
                        pagination={false}

                        dataSource={indexes}
                        columns={index_columns}
                        rowKey="code"
                    />
                    <Divider style={{ marginBottom: 32 }} />
                    <div className={styles.title}>设备测点</div>
                    <Table
                        style={{ marginBottom: 24 }}
                        pagination={false}

                        dataSource={parameters}
                        columns={parameter_column}
                        rowKey="code"
                    />
                </Card>
            </PageHeaderWrapper>
        );
    }
}

export default DeviceInfo;
